home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Plus 1995 #1
/
Amiga Plus 1995 #1.iso
/
fish-disketten
/
fish_901-910
/
d907
/
dd
/
analib
/
analib.doc
next >
Wrap
Text File
|
1994-12-13
|
7KB
|
261 lines
******************************************************************************
The File Analyser
(c) 1993 Martin Mares, MJSoft System Software
******************************************************************************
Copyright:
----------
The Analyser Library and its documentation is Copyright (c) Martin Mares,
MJSoft System Software, Prague, Czech Republic.
This archive can be freely redistributed, as long as all of its files are
included in their original form without any additions, deletions or
modifications, and no more than a nominal fee is charged for its distribution.
All copyright notices in the programs and accompanying documentation files
must remain on their places. Also '.displayme' and other similar files may
not be added. This is generally known as FREEWARE.
Special permission is given to Fred Fish to distribute this program on his
"Fish Disks".
This software is provided "AS IS" without warranty of any kind, either
expressed or implied. The author is not responsible for any damage caused by
it.
The library itself (analyser.library) can be distributed with any software
package, either commercial or non-commercial.
To maintain compatibility, you shouldn't make any changes on the library.
Updates will be released by the author.
What analyser.library does:
---------------------------
Some time ago, I wrote small program, which tried to analyse files and
estimate their types. It was only a joke, but when I were working on DD, I
thought that it could be useful to include the analyser in it. But it seemed
to be interesting to include the analyser in some different programs (file
requesters etc.), therefore I have converted it to this library.
Library functions:
------------------
==============================================================================
AnaName(A0=Name,A3=DataNode,D1=Size,D2=AnaMode,D3=ProtBits)
FUNCTION
Analyse file name, size and protection bits.
INPUTS
Name = pointer to file name
DataNode = pointer to data node of this file
Size = file size (used for detection of empty files)
AnaMode = analysis mode
ANAMO_SIMPLE - analyse file name only
ANAMO_CONTENTS - analyse file contents only
ANAMO_GOOD - analyse name, if it isn't enough, analyse file contents
ANAMO_FULL - analyse name and contents, find the best alternative
ProtBits = file protection bits (used to detect scripts)
RESULT
Zero in case the contents analysis hasn't to be performed.
(ANAMO_SIMPLE: always 0, ANAMO_CONTENTS and ANAMO_FULL: always -1,
ANAMO_GOOD: -1 only if the name analysis has failed)
DataNode->d_nclass contains name classification.
SEE ALSO
AnaContents, AnaEstimate
==============================================================================
AnaContents(A0=FileData,A3=DataNode,D0=Size)
FUNCTION
Analyse contents of first max. 488 bytes of the file. (The magic number
488 is the smallest possible size of file data block. It allows to read all
data needed for the analysis without reading of multiple sectors.)
You should not call AnaContents without calling AnaName first.
INPUTS
FileData = pointer to the buffer, which is filled with file contents
DataNode = pointer to file node
Size = size of file data (max. 488)
RESULT
DataNode->d_cclass contains the classification.
SEE ALSO
AnaName, AnaEstimate
==============================================================================
AnaEstimate(A1=DataNode,D0=AnaMode)
FUNCTION
Estimate final classification. You should call this function after
AnaName and (sometimes) AnaContents.
INPUTS
DataNode = pointer to file node
AnaMode = required analysis mode (see AnaName)
bit 8 of this parameter means "Exclude all non-reliable classes"
The most reliable method is ANAMO_FULL + ANAMO_RELIABLE
RESULT
DataNode->d_class contains final file classification
DataNode->d_subclass contains file subclass
(Only IFF files have the subclass now - it's the type of IFF (8SVX etc.))
SEE ALSO
AnaName, AnaContents, AnaMsg
==============================================================================
AnaMsg(A0=DataNode,A1=LineBuf)
FUNCTION
Construct file class text according to previous file analysis. AnaEstimate
should be called before it.
This function finds the class text and appends the subclass.
INPUTS
DataNode = pointer to file node
LineBuf = buffer you want to store the text to (minimally 80 bytes)
RESULT
LineBuf holding the null-terminated string.
SEE ALSO
AnaPlur, AnaText, AnaEstimate
==============================================================================
AnaPlur(D0=Class,A0=LineBuf)
FUNCTION
Construct file class name in plural. Subclass is not appended to the name.
INPUTS
Class = file class number
LineBuf = buffer you want to store the string to (minimally 80 bytes)
RESULT
LineBuf filled with the message (preceeded by two space characters).
SEE ALSO
AnaMsg, AnaText
==============================================================================
AnaGetMax
FUNCTION
Get number of file classes.
INPUTS
None.
RESULT
Number of file classes (it's the number of the last class + 1).
==============================================================================
AnaText(D0=Class)
FUNCTION
Get file class text without subclass. Used mostly for sorting.
INPUTS
Class = file class number
RESULT
Pointer to name of the class.
SEE ALSO
AnaMsg, AnaPlur
==============================================================================
AnaSortTab(A0=ArpBase) (V2)
FUNCTION
Create the sorting tables.
The first table is a sequence of words presenting the class numbers
arranged in alphabetical (read: ASCII) order.
The second one contains the inverse permutation to the first one, which is
very useful for sorting by analysis result (you can sort by TAB2[i] instead of
AnaText(i), which is significantly faster, because you haven't to compare any
strings).
For each i in <0;AnaGetMax()), you can really say:
(a) TAB1[TAB2[i]] = i
(b) NAME[i] < NAME[j] equals to TAB2[i] < TAB2[j]
INPUTS
ArpBase = base of opened arp.library (this library is used for sorting
of the tables and it cannot be opened twice by the same process!)
RESULT
Pointer to two long words representing addresses of the sorting tables.
If there isn't enough memory, 0 will be returned.
NOTES
There is no way to remove the sorting tables without removing the analyser
library, but if there isn't enough memory, the library will be expunged and
the tables will be properly deallocated. This eats some memory (4*number of
known classes), but it makes repeated invocation of DD ANA F SORT AN
significantly faster than it was before.
==============================================================================
Notes:
------
Send all suggestions and bug reports to mjsoft@k332.feld.cvut.cz